package com.zhhs.jzcd.marketing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhhs.framework.aspectj.lang.annotation.Log;
import com.zhhs.framework.aspectj.lang.enums.BusinessType;
import com.zhhs.jzcd.marketing.domain.BaseExactMarketing;
import com.zhhs.jzcd.marketing.service.IBaseExactMarketingService;
import com.zhhs.framework.web.controller.BaseController;
import com.zhhs.framework.web.domain.AjaxResult;
import com.zhhs.common.utils.poi.ExcelUtil;
import com.zhhs.framework.web.page.TableDataInfo;

/**
 * 精准营销Controller
 *
 * @author ruoyi
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/jzcd/marketing")
public class BaseExactMarketingController extends BaseController
{
    @Autowired
    private IBaseExactMarketingService baseExactMarketingService;

    /**
     * 查询精准营销列表
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseExactMarketing baseExactMarketing)
    {
        startPage();
        List<BaseExactMarketing> list = baseExactMarketingService.selectBaseExactMarketingList(baseExactMarketing);
        return getDataTable(list);
    }

    /**
     * 导出精准营销列表
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:export')")
    @Log(title = "精准营销", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseExactMarketing baseExactMarketing)
    {
        List<BaseExactMarketing> list = baseExactMarketingService.selectBaseExactMarketingList(baseExactMarketing);
        ExcelUtil<BaseExactMarketing> util = new ExcelUtil<BaseExactMarketing>(BaseExactMarketing.class);
        util.exportExcel(response, list, "精准营销数据");
    }

    /**
     * 获取精准营销详细信息
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(baseExactMarketingService.selectBaseExactMarketingById(id));
    }

    /**
     * 新增精准营销
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:add')")
    @Log(title = "精准营销", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseExactMarketing baseExactMarketing)
    {
        return toAjax(baseExactMarketingService.insertBaseExactMarketing(baseExactMarketing));
    }

    /**
     * 修改精准营销
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:edit')")
    @Log(title = "精准营销", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseExactMarketing baseExactMarketing)
    {
        return toAjax(baseExactMarketingService.updateBaseExactMarketing(baseExactMarketing));
    }

    /**
     * 删除精准营销
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:remove')")
    @Log(title = "精准营销", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseExactMarketingService.deleteBaseExactMarketingByIds(ids));
    }

    /**
     * 渠道类型下拉框
     */
    @GetMapping("/channelType")
    public AjaxResult getChannelType(){
        return AjaxResult.success(baseExactMarketingService.getChannelType());
    }

    /**
     * 精准营销审核状态分类列表
     */
    @PreAuthorize("@ss.hasPermi('jzcd:marketing:list')")
    @GetMapping("/getStatusList")
    public TableDataInfo getStatusList(String status){
        startPage();
        List<BaseExactMarketing> list = baseExactMarketingService.selectBaseExactMarketingListByStatus(status);
        return getDataTable(list);
    }

}
